<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <title>收益查询</title>
    <link rel="stylesheet" href="../../styles/h5/reset.min.css"/>
    <link rel="stylesheet" href="../../styles/h5/errortankuang.css"/>
    <!--以上为公共css样式-->
    <link rel="stylesheet" href="../../styles/h5/mymain.css"/>

    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery-1.9.1.min.js"></script>
    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery.modal.js"></script>
    <!--以上为公共js文件-->

</head>
<body class="body-color">
<div class="container">
    <div class="qb-data">
        <select id="select" name="">
            <!--<option value="">2017年1月</option>-->
        </select>
        <span class="zz-downNormal-jj"></span>
    </div>
    <div class="qb-con">
        <div class="qb-num">
            <p><span>累计总收益（元）</span><img src="../../image/h5/wh.png" id="zz-prompt-icon-jj" alt=""/></p>
        </div>
        <div class="qb-money"></div>
        <div class="qb-nogains hide">
            <img src="../../image/h5/kong.png" alt=""/>
            <p>本月还没有收益哦</p>
        </div>
    </div>
</div>
<div class="zz-list margin-top16">
    <ul>
        <!--<li>
            <span class="fl">2017-09-18</span>
            <span class="fr">+<span>5.62</span>元</span>
        </li>-->
    </ul>
</div>
</body>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/utils.js"></script>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/index.js"></script>
<script charset="utf-8" type="text/javascript">

    var $select = $("#select");
    var choiceMonth = "";
    var resultList = "";
    var yearMonth = "";
    var choiceMonthArr = '';
    $("#zz-prompt-icon-jj").click(function () {
        new $.modal({
            title: '提示',//弹框title
            content: '累计总收益包含已到账收益和其他未到账收益，仅做参考，实际以到账为准',//弹框内容
//            serviceCharge:"服务费￥100元，到账金额3433元",
            confirm: "我知道了",//确认按钮里面内容
            isshowclosebtn: false,//是否显示取消按钮
            showcontent: false,//false为弹出框组件二，true为弹出框组件一
            closecallback: function () {
            },//点击关闭时触发事件
            surecallback: function () {
                //点击确定时触发事件
            }
        }).show();
    });

    //初始化月份
    $.ajax({
        url: utils.ajaxUrl()+"h5/fund/opendAccount/getYearMonths",
        data:{
        	months:3
        },
        async: false,
        type: 'get',
        success: function (res) {
            var res = JSON.parse(res);
            console.log(res);
            if (res && res.retCode == '0000') {
                var months = res["resultList"];
                var str = '';
                for (var i = 0; i < months.length; i++) {
                    var curMonths = months[i];
                    var curMonthsArr = months[i].split("-");
                    var yearMonths = curMonthsArr[0] + "年" + curMonthsArr[1] + "月";
                    str += '<option value="' + curMonths + '">' + yearMonths + '</option>';
                }
                 $select.html(str);
                choiceMonth = $select.find("option:selected").attr("value");
                choiceMonthArr = choiceMonth.split("-");
                yearMonth = choiceMonthArr[0] + choiceMonthArr[1];
                //console.log(yearMonth);
                ajaxInitial();
            } else {
                utils.error("sx.png", "啊哦，数据异常");
            }
        },
        error: function () {
            utils.error("wlyc.png", "啊哦，连接不到网络呢");
        }
    });


    function ajaxInitial() {
        $.ajax({
            url: utils.ajaxUrl()+"h5/fund/opendAccount/getIncomeDetailList",
            data: {
                yearMonth: yearMonth
            },
            async: false,
            type: 'get',
            success: function (res) {
                var res = JSON.parse(res);
                console.log(res);
                if (res && res.retCode == '0000') {
                    $(".qb-money").html(utils.comma(res.totalAmt));
                    resultList = res.resultList;
					if(resultList == null || resultList.length==0){
					    $(".qb-nogains").show();
					    $(".qb-money").hide();
					    $("body").css("background","#fff");
					} else {
						$(".qb-nogains").hide();
					    $(".qb-money").show();
					    $("body").css("background","#eee");
					    bindHTML();
					}
                } else {
                    utils.error("sx.png", "啊哦，数据异常");
                }
            },
            error: function () {
                utils.error("wlyc.png", "啊哦，连接不到网络呢");
            }
        });
    }
    function bindHTML() {
        var str = '';
        for (var i = 0; i < resultList.length; i++) {
            var curData = resultList[i];
            str += '<li>';
            str += '<span class="fl">' + curData.proFitDate + '</span>';
            str += '<span class="fr">+<span>' + curData.lastDayProFit + '</span>元</span>';
            str += '</li>';
        }
        $(".zz-list ul").html(str);
    }
    $(function () {
        $select.change(function () {
            choiceMonth = $select.find("option:selected").attr("value");
            choiceMonthArr = choiceMonth.split("-");
            yearMonth = choiceMonthArr[0] + choiceMonthArr[1];
            ajaxInitial();
        });
    });
</script>
</html>
